import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import {request} from 'network/request.js'
Vue.prototype.$request = request

import 'assets/css/normalize.css'

import Vant from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);

import 'amfe-flexible/index.min.js'

// import 'assets/js/derective.js'

import vueTouch from 'kim-vue-touch'
Vue.use(vueTouch)

// 复制功能
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

router.beforeEach((to, from, next) => {
  let token = sessionStorage.getItem('mobileToken')

  // 如果是去登录页面, 就移除缓存的token
  if(to.path == '/Login' && !token){
    sessionStorage.removeItem('mobileToken')
  }

  // 每次跳转检测本地token状态
  if(!token && to.path != '/Login'){
    return next({path: '/'})
  }

  next()

})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
